package com.ljfiction.book.MyView;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.HorizontalScrollView;

/**
 * Created by admin on 2017/8/21.
 */

public class ObservableHorizontalScrollView extends HorizontalScrollView {
    public interface HorizontalScrollViewListener {

        void onScrollChanged(ObservableHorizontalScrollView HorizontalScrollView, int x, int y,
                             int oldx, int oldy);

    }

    private ObservableHorizontalScrollView.HorizontalScrollViewListener HorizontalScrollViewListener = null;

    public ObservableHorizontalScrollView(Context context) {
        super(context);
    }

    public ObservableHorizontalScrollView(Context context, AttributeSet attrs,
                                int defStyle) {
        super(context, attrs, defStyle);
    }

    public ObservableHorizontalScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setHorizontalScrollViewListener(ObservableHorizontalScrollView.HorizontalScrollViewListener HorizontalScrollViewListener) {
        this.HorizontalScrollViewListener = HorizontalScrollViewListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (HorizontalScrollViewListener != null) {
            HorizontalScrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
        }
    }
}
